﻿<cfscript>
/** 
* Senate Frameworks schemaProperty
* 
* @hint "The schema course property object handler." 
*/ 

component 
	displayname="public.service.handler.schemaProperty" 
	output=false 
	accessors=true 
	{

	/* PROPERTIES */
	property type="boolean" name="DegreeCourse" default="false" hint="是否学位课";
		
	property type="boolean" name="SecondDegree" default="false" hint="是否双学位培养方案课程";
	property type="boolean" name="AssistCourse" default="false" hint="是否辅修专业课程";
	
	property type="boolean" name="CommitView" default="false" hint="是否已审核";
	
	/**
	* @hint "初始化对象"
	* 
	* @DegreeCourse "是否学位课"
	* @SecondDegree "是否双学位培养方案课程"
	* @AssistCourse "是否辅修专业课程"
	* @CommitView "是否已审核"
	*/
	public public.service.handler.schemaProperty function init( boolean DegreeCourse=false, boolean SecondDegree=false, boolean AssistCourse=false, boolean CommitView=false ) output=false {
			
		setDegreeCourse( arguments.DegreeCourse );
		setSecondDegree( arguments.SecondDegree );
		setAssistCourse( arguments.AssistCourse );
		setCommitView( arguments.CommitView );

		return this;
	}

	/**
	* @hint "将上述属性转换为属性字符串"
	*/
	public string function stringProperty() output=false {
		
		var prop = "";
		
		/* 执行序列化 */
		if (getDegreeCourse()) { prop = prop & "1"; } else { prop = prop & "0"; }
		if (getSecondDegree()) { prop = prop & "1"; } else { prop = prop & "0"; }
		if (getAssistCourse()) { prop = prop & "1"; } else { prop = prop & "0"; }
		if (getCommitView()) { prop = prop & "1"; } else { prop = prop & "0"; }
		
		return left(prop & "000000000000000000000000000000", 20);
	}
	
	/**
	* @hint "将属性字符串转换为对象属性"
	* 
	* @fString "属性字符串"
	*/
	public void function parseProperty( required string fString ) output=false {
		
		var i = 0;
		
		for (i=1; i <= len(arguments.fString); i++) {
			
			switch (i) {
				
				case 1:
					/* 第1位 是否学位课 */
					if (yesNoFormat(mid(arguments.fString, i, 1))) { setDegreeCourse(true); } else { setDegreeCourse(false); }
					break;

				case 2:
					/* 第2位 是否双学位培养方案课程 */
					if (yesNoFormat(mid(arguments.fString, i, 1))) { setSecondDegree(true); } else { setSecondDegree(false); }
					break;
				
				case 3:
					/* 第3位 是否辅修专业课程 */
					if (yesNoFormat(mid(arguments.fString, i, 1))) { setAssistCourse(true); } else { setAssistCourse(false); }
					break;

				case 4:
					/* 第4位 是否已审核 */
					if (yesNoFormat(mid(arguments.fString, i, 1))) { setCommitView(true); } else { setCommitView(false); }
					break;
					
					

			}
		}
			
	}
		
}
</cfscript>